const express = require('express');
const config = require('./config/index')
const path = require('path')
const port = process.env.PORT || config.build.port;
const app = express();
const router = express.Router();
//app.engine('html',require('express-art-template'))


router.get('/', function(req, res ,next){
  req.url = '/index.html'
  // res.render( '../index.html') ;
    next();
})
app.use(router);
const data = require('./data.json')
const seller = data.seller
const goods = data.goods
const ratings = data.ratings
const aipRoutes = express.Router();
aipRoutes.get('/seller', function(req, res){
  return res.json({
    status: 0,
    message: seller
  })
})
/*
app.all('*', function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By",' 3.2.1')
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
});*/

aipRoutes.get('/goods', function(req, res){
  return res.json({
    status: 0,
    message: goods
  })
})

aipRoutes.get('/ratings', function(req, res){
  return res.json({
    status: 0,
    message: ratings
  })
})

app.use('/api', aipRoutes);
app.use(express.static('./dist'));



module.exports = app.listen('3001',function(){
  console.log('3001 run');
})

